package com.auth.web.auth;

import com.auth.token.app.UserInfo;

/**
 * 用于存储用户会话信息
 */
public class UserContext {

    private static final ThreadLocal<UserInfo> USER_INFO_LOCAL = new ThreadLocal<>();

    public static boolean isLogin() {
        return USER_INFO_LOCAL.get() != null;
    }

    public static void setUserInfo(UserInfo userInfo) {
        USER_INFO_LOCAL.set(userInfo);
    }

    public static UserInfo getUserInfo() {
        return USER_INFO_LOCAL.get();
    }

    public static void clear() {
        USER_INFO_LOCAL.remove();
    }
}
